package com.idea.zd.sys.quartz;

import com.jfinal.kit.HttpKit;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.logging.Logger;

import static java.util.logging.Logger.*;

public class IqiyiJobHour implements Job {
    private static final Logger log = getLogger(String.valueOf(IqiyiJobHour.class));
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {


        /*for(int i = 1;i <= 500;i++ ){

            if(HttpKit.get("http://app.fansiji.com/h5/iqiyi/Home/Api/ApiNum/getVideoUrl?page="+i+"").contains("error")){
                log.info("成功周时"+i);
                System.out.println("成功周时"+i);
                continue;
            }
        }

        for(int i = 1;i <= 500;i++ ){

            if(HttpKit.get("http://app.fansiji.com/h5/iqiyi/Home/Api/ApiNum/getMonthVideoUrl?page="+i+"").contains("error")){
                log.info("成功月时"+i);
                System.out.println("成功月时"+i);
                continue;
            }
        }*/

        IqiyiJob job1 = new IqiyiJob(100,1);
        IqiyiJob job2 = new IqiyiJob(200,101);
        IqiyiJob job3 = new IqiyiJob(300,201);
        IqiyiJob job4 = new IqiyiJob(400,301);
        IqiyiJob job5 = new IqiyiJob(500,401);
        IqiyiJob2 joby1 = new IqiyiJob2(100,1);
        IqiyiJob2 joby2 = new IqiyiJob2(200,101);
        IqiyiJob2 joby3 = new IqiyiJob2(300,201);
        IqiyiJob2 joby4 = new IqiyiJob2(400,301);
        IqiyiJob2 joby5 = new IqiyiJob2(500,401);
        Thread t1 = new Thread(job1,"线程1");
        Thread t2 = new Thread(job2,"线程2");
        Thread t3 = new Thread(job3,"线程3");
        Thread t4 = new Thread(job4,"线程4");
        Thread t5 = new Thread(job5,"线程5");
        Thread t6 = new Thread(joby1,"线程6");
        Thread t7 = new Thread(joby2,"线程7");
        Thread t8 = new Thread(joby3,"线程8");
        Thread t9 = new Thread(joby4,"线程9");
        Thread t10 = new Thread(joby5,"线程10");

        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
        t6.start();
        t7.start();
        t8.start();
        t9.start();
        t10.start();
        try {
            t1.join();
            t2.join();
            t3.join();
            t4.join();
            t5.join();
            t6.join();
            t7.join();
            t8.join();
            t9.join();
            t10.join();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        HttpKit.post("http://app.fansiji.com/h5/iqiyi/Home/week","");
        //log.info("http://app.fansiji.com/h5/iqiyi/Home/week");
        //System.out.println("http://app.fansiji.com/h5/iqiyi/Home/week");
        HttpKit.post("http://api.fansiji.com/sys_db/getAiqiyiUrl","");
        //log.info("http://api.fansiji.com/sys_db/getAiqiyiUrl");
        //System.out.println("http://api.fansiji.com/sys_db/getAiqiyiUrl");
        HttpKit.post("http://app.fansiji.com/h5/iqiyi/Home/index","");
        //log.info("http://app.fansiji.com/h5/iqiyi/Home/index");
        //System.out.println("http://app.fansiji.com/h5/iqiyi/Home/index");
        HttpKit.post("http://app.fansiji.com/h5/iqiyi/Home/month","");
        //log.info("http://app.fansiji.com/h5/iqiyi/Home/month");
        //System.out.println("http://app.fansiji.com/h5/iqiyi/Home/month");
    }

    public static void main (String [] args){
        IqiyiJob job1 = new IqiyiJob(100,1);
        IqiyiJob job2 = new IqiyiJob(200,101);
        IqiyiJob job3 = new IqiyiJob(300,201);
        IqiyiJob job4 = new IqiyiJob(400,301);
        IqiyiJob job5 = new IqiyiJob(500,401);
        IqiyiJob2 joby1 = new IqiyiJob2(100,1);
        IqiyiJob2 joby2 = new IqiyiJob2(200,101);
        IqiyiJob2 joby3 = new IqiyiJob2(300,201);
        IqiyiJob2 joby4 = new IqiyiJob2(400,301);
        IqiyiJob2 joby5 = new IqiyiJob2(500,401);
        Thread t1 = new Thread(job1,"线程1");
        Thread t2 = new Thread(job2,"线程2");
        Thread t3 = new Thread(job3,"线程3");
        Thread t4 = new Thread(job4,"线程4");
        Thread t5 = new Thread(job5,"线程5");
        Thread t6 = new Thread(joby1,"线程6");
        Thread t7 = new Thread(joby2,"线程7");
        Thread t8 = new Thread(joby3,"线程8");
        Thread t9 = new Thread(joby4,"线程9");
        Thread t10 = new Thread(joby5,"线程10");

        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
        t6.start();
        t7.start();
        t8.start();
        t9.start();
        t10.start();
        try {
            t1.join();
            t2.join();
            t3.join();
            t4.join();
            t5.join();
            t6.join();
            t7.join();
            t8.join();
            t9.join();
            t10.join();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
